<style scoped lang="less">
// 侧边栏
.right-aside {
  // width: 300px;
  // position: fixed;
  // 分割线的外边距 上下 距离
  .ivu-divider-horizontal {
    margin: 10px 0;
  }
  .request-option-detail {
    // margin-top: 9px;
    .ivu-form-item-label {
      font-size: 15px;
    }
    // 表单元素上下距离
    .ivu-form-item {
      margin-bottom: 10px;
    }
  }
  .request-option-button {
    margin-top: 9px;
    height: 29px;
  }
}
</style>
<template>
  <div class="right-aside">
    <div v-if="roomInfo.roleKey === 'student'">
      <Card>
        <p slot="title">我的答疑室</p>
        <div class="room-student-uers-info">
          <com-room-list-user-info :roomInfo="roomInfo"></com-room-list-user-info>
        </div>
        <Divider/>
        <div class="room-list">
          <p>我加入的答疑室：</p>
          <p v-for="room in roomInfo.roomList">
            <Button type="text" :to="{path:'/answer-room-details/'+room.tid}">{{room.teacherName}}</Button>
          </p>
        </div>
        <!-- <Divider/> -->
      </Card>
    </div>
    <div v-if="roomInfo.roleKey === 'teacher'">
      <Card title="我的答疑室" :bordered="false">
        <div>
          <com-room-list-user-info :roomInfo="roomInfo"></com-room-list-user-info>
          <Divider/>
          <p>
            我的答疑室：
            <span v-if="!(roomInfo.roomList)">暂未开通</span>
          </p>
          <div v-if="roomInfo.roomList" class="room-list">
            <p v-for="room in roomInfo.roomList">
              <Button type="text" :to="{path:'/answer-room-details/'+room.tid}">点击进入</Button>
            </p>
          </div>
          <div v-else>
            <Button type="primary" @click="openRoomBtn">开通答疑室</Button>
          </div>
          <div class="open-room-wrap">
            <Modal
              title="开通答疑室"
              :value="OpenRoomModalShow"
              :mask-closable="false"
              :closable="true"
              :draggable="true"
            >
              <com-open-room
                :roomForm="{}"
                @open-room-success="openRoomSuccess"
                ref="OpenRoomFormRef"
              ></com-open-room>
              <div slot="footer" v-if="true">
                <Button type="text" size="large" @click="openRoomCancelBtn">取消</Button>
                <Button type="primary" size="large" @click="HandleOpenBtm">保存</Button>
              </div>
            </Modal>
          </div>
        </div>
      </Card>
    </div>
    <div v-if="roomInfo.roleKey === 'admin'">
      <Card title="我的答疑室" :bordered="false">
        <div>
          <com-room-list-user-info :roomInfo="roomInfo"></com-room-list-user-info>
        </div>
      </Card>
    </div>
  </div>
</template>
<script>
import { getToken } from '@/libs/util'
import Vue from 'vue'
import ComOpenRoom from './ComOpenRoom.vue'
import ComRoomListUserInfo from './ComRoomListUserInfo'

export default {
  props: ['roomInfo'],
  components: {
    ComOpenRoom,
    ComRoomListUserInfo
  },
  data () {
    return {
      loadMoreValue: 0,
      conditionForm: {},
      // 答疑室相关
      OpenRoomModalShow: false
    }
  },

  methods: {
    //* *******开通答疑室start******** */
    openRoomBtn () {
      this.OpenRoomModalShow = true
    },
    HandleOpenBtm () {
      this.$refs.OpenRoomFormRef.handleOpen()
    },
    // 开通答疑室取消
    openRoomCancelBtn () {
      this.OpenRoomModalShow = false
    },
    // 答疑室开通成功的回调
    openRoomSuccess () {
      this.OpenRoomModalShow = false
    },
    //* *******开通答疑室 end******** */

    // 获取下拉框列表
    getAllData () {
      this.$httpUtil.asyncGet('web/raroom/getAllData', {}, res => {
        if (res.data.code === 200) {
          let data = res.data.records
          this.teacherName = data.teacherName
          this.allData.professionList = data.professionList
          this.allData.courseList = data.courseList
          this.allData.proCourseRalatelist = data.proCourseRalatelist
          this.allData.studentList = data.studentList
          this.allData.proStudentRelateList = data.proStudentRelateList

          this.studentSelectList = data.studentList
          this.courseSelectList = data.courseList
        } else {
          this.$Message.success(res.data.msg)
        }
      })
    },

    // 初始化方法
    init () {
      // this.getAllData();
    }
  },
  computed: {
    getLogin () {
      let token = getToken()
      if (token) {
        return true
      } else {
        return false
      }
    }
  },
  mounted () {
    this.init()
  },
  watch: {
    getLogin (v) {
      debugger
      this.isLogin.v
    }
  }
}
</script>
